#pragma once

#include<math.h>

class Location
{
public:
	Location(float x , float y)
		:X(x),
		Y(y)
	{
	}
	Location()
		:X(0.0),
		Y(0.0)
	{
	}
	float GetDistance(const Location& anotherLocation) const
	{
		float dx = X - anotherLocation.X;
		float dy = Y - anotherLocation.Y;
		return sqrt(dx * dx + dy * dy);
	}
	void MoveTowardLocation(const Location& targetPosition , float distance)
	{
		float length = GetDistance(targetPosition);
		if(length > 0.0)
		{
			float delta = distance / length;
			X += (targetPosition.X - X) * delta;
			Y += (targetPosition.Y - Y) * delta;
		}
	}
	void Set(const float& x , const float& y)
	{
		X = x;
		Y = y;
	}
	//--
	float X;
	float Y;
};